<?php 
/*
 module:		用户列表
 create_time:	2024-05-06 11:54:49
 author:		
 contact:		
*/

namespace app\admin\service\Users;
use app\admin\model\Users\Index;
use think\exception\ValidateException;
use xhadmin\CommonService;

class IndexService extends CommonService {


 /**start**/
	/*
 	* @Description  列表数据
 	*/
	public static function indexList($where,$field,$order,$limit,$page){
		try{
//			$res = Index::where($where)->field($field)->order($order)->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
            $res =
                db("user")
                ->alias("u")
                ->join("user_wechat uw","u.uid = uw.uid","left")
                ->join("user_subordinate us","uw.uid = us.uid","left")
                ->join("user_wechat pu","us.pid = pu.uid","left")
                ->order("u.uid desc")
                ->field("u.phone,uw.uid as u_id,uw.nickname,uw.add_time,uw.headimgurl,uw.sex,uw.city,uw.province,uw.openid,us.pid,pu.nickname as pnickname,pu.headimgurl as pheadimgurl	")
                ->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
		return ['rows'=>$res['data'],'total'=>$res['total']];
	}

    /**end**/



}

